package com.nbcio.pm.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.nbcio.common.tenant.core.TenantEntity;
import com.nbcio.pm.domain.vo.PmTaskVo;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

/**
 * 任务对象 pm_task
 *
 * @author nbacheng
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pm_task")
@AutoMapper(target = PmTaskVo.class, reverseConvertGenerate = false)
public class PmTask extends TenantEntity {

    /**
     * 任务ID
     */
    @TableId(value = "task_id", type = IdType.AUTO)
    private Long taskId;

    /**
     * 项目ID
     */
    @TableField("project_id")
    private Long projectId;

    /**
     * 父任务ID
     */
    @TableField("parent_id")
    private Long parentId;

    /**
     * 任务名称
     */
    @TableField("task_name")
    private String taskName;

    /**
     * 任务编码
     */
    @TableField("task_code")
    private String taskCode;

    /**
     * 任务描述
     */
    @TableField("description")
    private String description;

    /**
     * 任务类型：task-任务，milestone-里程碑
     */
    @TableField("task_type")
    private String taskType;

    /**
     * 任务状态：pending-待开始，active-进行中，completed-已完成，paused-已暂停，cancelled-已取消
     */
    @TableField("status")
    private String status;

    /**
     * 优先级：low-低，medium-中，high-高，urgent-紧急
     */
    @TableField("priority")
    private String priority;

    /**
     * 进度百分比
     */
    @TableField("progress")
    private BigDecimal progress;

    /**
     * 计划开始日期
     */
    @TableField("start_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate startDate;

    /**
     * 计划结束日期
     */
    @TableField("end_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate endDate;

    /**
     * 实际开始日期
     */
    @TableField("actual_start_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate actualStartDate;

    /**
     * 实际结束日期
     */
    @TableField("actual_end_date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate actualEndDate;

    /**
     * 预估工时
     */
    @TableField("estimated_hours")
    private BigDecimal estimatedHours;

    /**
     * 实际工时
     */
    @TableField("actual_hours")
    private BigDecimal actualHours;

    /**
     * 负责人ID
     */
    @TableField("assignee_id")
    private Long assigneeId;

    /**
     * 报告人ID
     */
    @TableField("reporter_id")
    private Long reporterId;

    /**
     * 排序
     */
    @TableField("sort_order")
    private Integer sortOrder;

    // 关联字段（非数据库字段）
    @TableField(exist = false)
    private String assigneeName;

    @TableField(exist = false)
    private String reporterName;

    @TableField(exist = false)
    private String projectName;

    @TableField(exist = false)
    private List<PmTask> subTasks;

    @TableField(exist = false)
    private List<PmTaskDependency> dependencies;
}
